package com.cq.hd.member.api.dto;

import com.cq.hd.common.utils.LocalDateUtil;
import com.cq.hd.common.utils.StringUtils;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.time.LocalDateTime;

public class WxSubscribeRecordSaveDto implements Serializable {

    @ApiModelProperty(value = "用户id")
    private Long userId;

    @ApiModelProperty(value = "openid")
    private String openid;

    @ApiModelProperty(value = "关注时间")
    private LocalDateTime subscribeTime;

    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    public String getOpenid() {
        return openid;
    }

    public void setOpenid(String openid) {
        this.openid = openid;
    }

    public LocalDateTime getSubscribeTime() {
        return subscribeTime;
    }

    public void setSubscribeTime(String subscribeTime) {
        if (!StringUtils.isBlank(subscribeTime)) {
            try {
                this.subscribeTime = LocalDateUtil.toLongToLocalDateTime(Long.parseLong(subscribeTime) * 1000);
            } catch (Exception e) {
                this.subscribeTime = LocalDateTime.now();
            }
        } else {
            this.subscribeTime = LocalDateTime.now();
        }
    }

}
